<?php
namespace Feedback\Controller;
use \Com\Page;

class AdminController extends AppController{

	protected $message;

	public function _initialize(){
		parent::_initialize();
		$top_nav = array(
			array('name'=>'反馈列表','url'=>U('Feedback/Admin/index'),'tab'=>array('index')),
		);
		$this->message = D('Common/Message');
		$this->assign('top_nav',$top_nav);
	}

	public function index(){
		$wherearr = array();

		$count = $this->message->where($wherearr)->count();
		$page = new Page($count,'15');
		$limit = $page->firstRow.','.$page->listRows;
		$field = "*";
		$order = "id desc";
		$list = $this->message->getListByMap($wherearr,$field,$limit,$order);
		$data = array('list'=>$list,'page'=>$page->show());

		$this->assign($data);
		$this->display();
	}

	public function dopost(){
		if(IS_POST){
			$data = $this->message->create();
			if (!$data) {
				$this->error($this->message->getError());
			}else{
				$result = $this->message->save();
				if($result){
					$this->success('回复成功！',U('Feedback/Admin/index'));
				}else{
					$this->error($this->message->getError());
				}
			}
		}else{
			$this->error("非法操作！");
		}
	}
}